/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SLE_DISCOVER_SEEK_PARCEL_H
#define SLE_DISCOVER_SEEK_PARCEL_H

#include <cstdint>
#include <memory>
#include "parcel.h"
#include "sle_seek_config.h"
#include "sle_address_parcel.h"
#include "sle_error_code.h"

namespace OHOS {
namespace NearLink {
namespace SleStandard {
class SeekParam : public Parcelable {
public:
    SeekParam() = default;
    explicit SeekParam(const SleSeekParam &param);
    ~SeekParam() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SeekParam *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToSleSeekParam(SleSeekParam &param) const;
    static bool CheckSeekParamArray(const uint8_t type[], const uint16_t interval[], const uint16_t window[]);
    static SleErrorCode CheckSeekParam(const SleSeekParam &param);

public:
    uint8_t addressType_;
    uint8_t repateFilter_;
    uint8_t filterPolicy_;
    uint8_t phys_;
    uint8_t type_[SLE_SEEK_PHY_MAX];
    uint16_t interval_[SLE_SEEK_PHY_MAX];
    uint16_t window_[SLE_SEEK_PHY_MAX];
};

class SeekResult : public Parcelable {
public:
    SeekResult() = default;
    explicit SeekResult(const SleSeekResult &result);
    ~SeekResult() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SeekResult *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToSleSeekResult(SleSeekResult &result) const;

public:
    uint8_t eventType_;
    SleAddress address_;
    SleAddress dirAddress_;
    uint8_t rssi_;
    uint8_t dataStatus_;
    uint8_t length_;
    std::unique_ptr<uint8_t[]> data_;
};
} // SleStandard
} // NearLink
} // OHOS

#endif // SLE_DISCOVER_SEEK_PARCEL_H